package demo.day05;

import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/7/21-07-21-14:41
 * @Description：demo.day05    猜数字游戏
 */
public class random_demo {
    public static void main(String[] args) {
        Set<Integer> set = new HashSet();
        Set<Integer> set_two = new HashSet<>();
        Random random = new Random();
        int num;
        while(set.size() < 20){
            num = random.nextInt(20)+1;
            set.add(num);
            if(num %2 == 0){
                set_two.add(num);
            }
        }
        System.out.println(set_two);
    }
//        Random rd = new Random();
//        int rd_num = rd.nextInt(100);
        //System.out.println(rd_num);
        //Grass_Num_game(rd_num);



    public static void Grass_Num_game(int rd_num) {
        System.out.println("游戏开始啦！");
        System.out.println("0—100中，猜猜我是哪个？您有10次机会哦，加油呀");
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int num;
        while(true){
            num = sc.nextInt();
            if(count>=10){
                System.out.println("次数用光啦，下次再来吧");
                break;
            }
            if(num == rd_num){
                System.out.println("运气真好！才" + count +"次，就猜对啦，");
                break;
            }else if(num <= rd_num){
                System.out.println("不对哦，往大点的数字猜猜");
            }else{
                System.out.println("不对呀，太大啦，往小数猜猜看喽");
            }
            count++;
        }
    }
}
